<template>
  <el-form v-if="curEmp" label-width="120px" label-position="left">
    <el-form-item :label="curEmp.USR_Name">{{ curEmp.USR_Phone }}</el-form-item>
    <el-form-item label="作业提成(%)">
      <el-input-number
        v-model="curEmp.EMP_JobRate"
        :min="-100"
        :max="100"
        label="请输入作业提成率"
        style="width: 200px"
      ></el-input-number>
    </el-form-item>
    <el-form-item label="业务提成(%)">
      <el-input-number
        v-model="curEmp.EMP_SaleRate"
        :min="-100"
        :max="100"
        label="请输入业务提成率"
        style="width: 200px"
      ></el-input-number>
    </el-form-item>
    <el-form-item label="经纪费(%)">
      <el-input-number
        v-model="curEmp.EMP_BrokerRate"
        :min="-100"
        :max="100"
        label="请输入经纪费"
        style="width: 200px"
      ></el-input-number>
    </el-form-item>
    <el-form-item label="作业提成扣除(%)">
      <el-input-number
        v-model="curEmp.EMP_BrokerDeductRate"
        :min="-100"
        :max="100"
        label="请输入作业扣除率"
        style="width: 200px"
      ></el-input-number>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" size="medium" @click="editEmployeeIncomeRate()">
        保存
      </el-button>
      <el-button type="text" @click="$emit('canceled')">取消</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import {
  getEmployee,
  editEmployeeIncomeRate,
} from '@/api/flowCenter/organiztion/employeeManage'
export default {
  props: ['empId'],
  data: function () {
    return {
      curEmp: null,
    }
  },
  watch: {
    empId(val) {
      this.getEmployee()
    },
  },
  methods: {
    getEmployee() {
      getEmployee(this.empId).then(({ data }) => {
        this.curEmp = data
      })
    },
    editEmployeeIncomeRate() {
      editEmployeeIncomeRate(this.curEmp).then(() => {
        this.$emit('saved')
      })
    },
  },
  created: function () {
    this.getEmployee()
  },
}
</script>
